$(function () {
    let newsid = localStorage.getItem("newsId");
    findByNewsId(newsid);
});

function findByNewsId(id) {
    let result = myAjax('/back/user/findByNewsId', 'get', {id: id,token:$.cookie("token")});
    setData(result.newsModel);//需要给数据  把后台数据拿到
}

function setData(data) {
    $("#newsId").val(data.id);
    $("#newsType").val(data.newsType);
    $("#newsTitle").val(data.newsTitle);
    $("#publisher").val(data.publisher);
    $("#newsContent").val(data.newsContent);
    $("#releaseTime").val(data.releaseTime);
}

function newsEdit() {
    let data = {};
    data.id = $("#newsId").val();
    data.newsType = $("#newsType").val();
    data.newsTitle = $("#newsTitle").val();
    data.publisher = $("#publisher").val();
    data.newsContent = $("#newsContent").val();
    data.releaseTime = $("#releaseTime").val();
    data.token =$.cookie("token");
    let result = myAjax('/back/news/newsEdit','post',data);
    if (result.count === 1) {
        alert("修改成功!");
        $("#right").load('/back/news/newsManage.html');
    } else {
        alert("修改失败!")
    }
}
function cancelEdit() {
    $("#right").load('/back/news/newsManage.html');
}